new Vue({
    el: ".box",
    data: {
        nums: [7, 8, 9, 4, 5, 6, 1, 2, 3, 0, ".", "+/-"],
        Keyoperator: ["＋", "－", "×", "÷"],
        operator: "",
        //显示器的数据
        result: "",
        //运算数1
        num1: 0,
        num2: 0,
        ispass: "j",
        flag: false,
    },
    methods: {
        remove() {
            console.log(222);

            let nums = String(this.result).split("");
            nums.pop();
            this.result = nums.join("");
            this.Valuestore();
        },
        Valuestore() {
            if (this.flag) {
                this.num2 =
                    parseFloat(this.result) == NaN ? 0 : parseFloat(this.result);

                console.log("num2:" + this.num2);
            } else {
                this.num1 =
                    parseFloat(this.result) === NaN ? 0 : parseFloat(this.result);
                console.log("num1:" + this.num1);
            }
        },
        clickNum(index) {
            if (index <= this.nums.length - 2) {
                this.result += String(this.nums[index]);
                this.Valuestore();
            } else {
                this.result = -parseFloat(this.result);
                this.Valuestore();
            }
        },
        //按下10的键
        click10(event) {
            this.result += event.target.innerText;
            this.Valuestore();
        },
        //按下
        passkey(index) {
            this.ispass = index;
        },
        upkey() {
            this.ispass = "j";
        },

        //符号
        fuhao(event) {
            this.operator = event.target.innerText;
            this.flag = true;
            this.result = "";
        },

        //清空
        empty() {
            this.result = "";
            this.flag = false;
        },
        jieguo() {
            console.log(this.operator);
            switch (this.operator) {
                case "＋":
                    this.result = parseFloat(this.num1) + parseFloat(this.num2);
                    break;
                case "－":
                    this.result = parseFloat(this.num1) - parseFloat(this.num2);
                    break;
                case "×":
                    this.result = parseFloat(this.num1) * parseFloat(this.num2);
                    break;
                case "÷":
                    this.result = parseFloat(this.num1) / parseFloat(this.num2);
                    break;
                default: {
                    this.result = 0;
                }
            }
            this.flag = false;
            this.num1 = this.result;
        },
    },




})